package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	signalChan := make(chan os.Signal, 1)

	cleanupDone := make(chan bool)

	signal.Notify(signalChan,
		os.Interrupt,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		var v interface{}
		for v = range signalChan {
			fmt.Println(v)
			fmt.Println("\nReceived an interrupt, stopping services...")
			cleanupDone <- true
		}
	}()
	<-cleanupDone
}
